@extends('layout')
@section('body')
    <div class="page-container">
        @yield('content')
    </div>
@stop
@push('script')
    <script type="text/javascript" src="{{url('/lib/My97DatePicker/4.8/WdatePicker.js')}}"></script>
    <script type="text/javascript" src="{{url('/lib/datatables/1.10.15/jquery.dataTables.min.js')}}"></script>
    <script type="text/javascript" src="{{url('/lib/laypage/1.2/laypage.js')}}"></script>
    <script type="application/javascript">
        SystemUtil.changeURLArg = function (url, arg, arg_val) {
            var pattern = arg + '=([^&]*)';
            var replaceText = arg + '=' + arg_val;
            if (url.match(pattern)) {
                var tmp = '/(' + arg + '=)([^&]*)/gi';
                tmp = url.replace(eval(tmp), replaceText);
                return tmp;
            } else {
                if (url.match('[\?]')) {
                    return url + '&' + replaceText;
                } else {
                    return url + '?' + replaceText;
                }
            }
            return url + '\n' + arg + '\n' + arg_val;
        };
        SystemUtil.showPager = function (cont, total, curr,limit,call) {
            laypage.render({
                elem:cont,
                limit:limit||10,
                layout: ['count', 'prev', 'page', 'next', 'limit', 'refresh', 'skip'],
                count: total, //通过后台拿到的总页数
                curr: curr, //初始化当前页
                jump: function (e) { //触发分页后的回调
                    if (e.curr != curr||e.limit!=limit) {
                        // console.log(SystemUtil.changeURLArg(SystemUtil.changeURLArg(location.href, "page", e.curr),'limit',e.limit));
                        if(call){
                            call(e.curr,e.limit);
                        }else{
                            location.href = SystemUtil.changeURLArg(SystemUtil.changeURLArg(location.href, "page", e.curr),'limit',e.limit);
                        }
                    }
                }
            });
        }
    </script>
    @stack('js')
@endpush
